#ifndef PLUGIN_CONFIG_H
#define PLUGIN_CONFIG_H
// #include <QWidget>
#include "../../IPlugin.h"
#include "ui_plugin_warn.h" // 包含生成的UI头文件
#include "warn_table.h"
QT_BEGIN_NAMESPACE
namespace Ui
{
    class plugin_warn;
}
QT_END_NAMESPACE

class plugin_warn : public IPlugin
{
    Q_OBJECT
    Q_INTERFACES(IPlugin)
    Q_PLUGIN_METADATA(IID "com.example.IPlugin/1.0" FILE "plugin_warn.json")

public:
    QString pluginName() const override { return "plugin_warn"; }
    QString version() const override { return "1.0"; }

    QWidget *createUI(QWidget *parent) override
    {
        pluginWidget = new QWidget(parent);
        plugin_warn_ui = new Ui::plugin_warn(); // 创建UI实例
        plugin_warn_ui->setupUi(pluginWidget);  // 设置UI到widget
        return pluginWidget;
    }
    void sendMessageToPlugin(const QString &msg) override;
    ~plugin_warn()
    {
        delete plugin_warn_ui; // 确保释放内存
    }

private:
    Ui::plugin_warn *plugin_warn_ui = nullptr; // UI指针成员
    QWidget *pluginWidget;
    warn_table mWarnTable;
    void processJsonCommand(const QString &jsonStr); // 解析json命令并处理
    void initUi();
};
#endif // PLUGIN_CONFIG_H
